using System.Collections.Generic;
using UnityEngine;

public class missilepool : MonoBehaviour
{
	public static missilepool instance;

	public List<missilemove> enablelist;

	public List<missilemove> disablelist;

	private missilemove tempbullet;

	public missilemove originalmissile;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
		}
	}

	public missilemove GetMissile()
	{
		if (disablelist.Count > 0)
		{
			tempbullet = disablelist[0];
			disablelist.RemoveAt(0);
			enablelist.Add(tempbullet);
			return tempbullet;
		}
		if (GlobalInf.CurrentQuality < (Quality)101)
		{
			tempbullet = enablelist[0];
			enablelist.RemoveAt(0);
			enablelist.Add(tempbullet);
			return tempbullet;
		}
		tempbullet = (UnityEngine.Object.Instantiate(originalmissile.gameObject) as GameObject).GetComponent<missilemove>();
		enablelist.Add(tempbullet);
		tempbullet.transform.parent = base.transform;
		return tempbullet;
	}

	public missilemove GetMissileduo()
	{
		if (disablelist.Count > 0)
		{
			tempbullet = disablelist[0];
			disablelist.RemoveAt(0);
			enablelist.Add(tempbullet);
			return tempbullet;
		}
		if (GlobalInf.CurrentQuality < (Quality)101)
		{
			tempbullet = enablelist[0];
			enablelist.RemoveAt(0);
			enablelist.Add(tempbullet);
			return tempbullet;
		}
		tempbullet = (UnityEngine.Object.Instantiate(originalmissile.gameObject) as GameObject).GetComponent<missilemove>();
		enablelist.Add(tempbullet);
		tempbullet.transform.parent = base.transform;
		return tempbullet;
	}

	public void RecycleMissile(missilemove b)
	{
		enablelist.RemoveAt(enablelist.IndexOf(b));
		UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
		disablelist.Add(b);
	}

	private void OnDestroy()
	{
		if (instance != null)
		{
			instance = null;
		}
	}
}
